<?

class FormNewTaskComment extends CFormModel{
    
    public $parent_id;
    public $task_id;
    public $text;
    
    public function rules(){
        return array(
            array('task_id, text', 'required'),
            array('parent_id, task_id', 'numerical', 'integerOnly'=>true),
        );
    }
    
    public function attributeLabels(){
        return array(
            'parent_id' => TaskModule::t('fields', 'Родительский комментарий'),
            'task_id' => TaskModule::t('fields', 'задача'),
            'text' => TaskModule::t('fields', 'Текст'),
        );
    }
    
    function save(){
        
        $TC = new TaskComment;
        $TC->text = $this->text;
        $TC->parent_id = $this->parent_id;
        $TC->user_id = Yii::app()->user->id;
        $TC->task_id = $this->task_id;
        $TC->time_create = time();
        $TC->save();
        return $TC;
        
    }
    
}
